<script setup>
  import {
    Card,
    CardMeta,
    Avatar,
    // Link,
    Button,
    Divider,
    Image,
    List,
    ListItem,
    // ListItemMeta,
    Row,
    Col,
    Tag,
  } from '@arco-design/web-vue';
  import { IconEdit } from '@arco-design/web-vue/es/icon';
  import { useRouter } from 'vue-router';
  import SearchHeader from '/@/views/jobs/components/SearchHeader.vue';
  import FilterCard from '/@/views/jobs/components/FilterCard.vue';
  const router = useRouter();

  // 选择条件进行筛选
  function handleSelect(val) {
    console.log('val:', val);
  }

  const avatarUrl =
    'https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp';

  function handleOpenDetails(item) {
    console.log('router:', router);
    router.push(`/jobs/detail/${item}`);
  }
</script>

<template>
  <div class="w-full">
    <SearchHeader class="!h-64" />
    <div class="py-[12px] box-border">
      <div class="w-[calc(100%-80px)] flex relative mx-auto">
        <div class="center flex-1 min-h-[calc(100vh-13rem-1240px)]">
          <FilterCard @select="handleSelect" class="mb-[10px]" />
          <Card :bordered="false" :hoverable="true">
            <Row v-for="item of 20" :key="item" class="mb-[10px]" @click="handleOpenDetails(item)">
              <Col :span="2" class="flex items-center justify-center">
                <Avatar :size="80" :image-url="avatarUrl" />
              </Col>
              <Col :span="22">
                <Row class="my-4">
                  <Col :span="2" class="text-center">
                    <Tag color="#165dff" size="small">置顶</Tag>
                  </Col>
                  <Col :span="22"> 【区块链远程】20K-35K/运维工程师/全球化区块链团队 </Col>
                </Row>
                <Row>
                  <Col :span="2" class="text-center">
                    <Tag color="blue" size="small">极星</Tag>
                  </Col>
                  <Col :span="22">毛毛 发布于 3 天前 </Col>
                </Row>
              </Col>
              <Divider />
            </Row>
          </Card>
        </div>
        <div class="rightt w-[266px] ml-[18px]">
          <!-- 发布岗位 -->
          <card hoverable :bordered="false" class="mb-[10px] text-center">
            <Button type="primary" size="large"><IconEdit class="mr-2" /> 发布岗位 </Button>
          </card>
          <!-- 发布岗位 -->
          <!-- 远程岗位推荐 -->
          <card class="hot-topic-block mb-[10px]" hoverable :bordered="false">
            <card-meta title="远程岗位推荐">
              <template #description>
                <divider style="margin: 0" />
                <List :bordered="false" :split="false" class="pt-2">
                  <list-item v-for="idx in 4" :key="idx" class="w-full !px-0 !py-2">
                    <div class="flex items-center overflow-hidden w-full cursor-pointer">
                      <Card class="w-full mr-[10px]">
                        <div class="hot-topic-title-more"
                          >【区块链远程】15K-30K*14薪/WEB前端工程师/海外区块链技术公司</div
                        >
                      </Card>
                    </div>
                  </list-item>
                </List>
              </template>
            </card-meta>
          </card>
          <!-- 远程岗位推荐 -->
          <!-- 广告区 -->
          <card class="ad-block mb-[10px]" hoverable :bordered="false">
            <template #cover>
              <div
                :style="{
                  height: '150px',
                  overflow: 'hidden',
                }"
              >
                <Image
                  width="100%"
                  height="100%"
                  fit="cover"
                  src="https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp"
                />
              </div>
            </template>
          </card>
          <!-- 广告区 -->
          <!-- 广告区 -->
          <card class="ad-block mb-[10px]" hoverable :bordered="false">
            <template #cover>
              <div
                :style="{
                  height: '150px',
                  overflow: 'hidden',
                }"
              >
                <Image
                  width="100%"
                  height="100%"
                  fit="cover"
                  src="https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp"
                />
              </div>
            </template>
          </card>
          <!-- 广告区 -->
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
  .user-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ad-block >>> .arco-card-body {
    padding: 0 !important;
  }

  .hot-topic-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hot-topic-title-more {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .hot-topic-block >>> .arco-list-item-main {
    width: 100%;
  }

  .select-block >>> .arco-list-item-meta,
  .select-block >>> .arco-list-item-meta-content,
  .select-block >>> .arco-list-item-meta-title {
    height: 100%;
  }

  .select-block >>> .arco-list-item-meta-title {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .select-block >>> .arco-list-item-content {
    height: calc(100% - 30px);
  }

  .select-block >>> .arco-list-item-action {
    height: 30px;
    line-height: 30px;
  }

  .select-block >>> .arco-list-item-main {
    height: 80px !important;
    padding-right: 6px;
    box-sizing: border-box;
  }
</style>
